{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "dd8cea81-7aff-4ea9-9b3d-bb0c55f2b8cf",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "from sklearn.datasets import load_iris\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "x, y = load_iris().data[:, 2:4], load_iris().target\n",
    "x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=1, test_size=0.33) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "5bf0d3b4-f8d3-4733-adc1-0227ae573345",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.98\n"
     ]
    }
   ],
   "source": [
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn.metrics import accuracy_score\n",
    "\n",
    "model = LogisticRegression()\n",
    "model.fit(x_train, y_train)\n",
    "ac = accuracy_score(y_test, model.predict(x_test))\n",
    "print(ac)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "88bdae93-a937-45eb-998f-28194ae94503",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from matplot.colors import ListedColormap\n",
    "import numpy as np\n",
    "t1=np.lispace(0,8,N)\n",
    "t2=np.linspace(0,3,m)\n",
    "x1,x2=np.meshgtid(t1,t2)\n",
    "x_new=np.stack(x1.flat,x2.flat).axis=1))\n",
    "y_predict=model.predict(x_new)\n",
    "y_hat=y_predict.reshape(x1.shape)\n",
    "iris_cmap=;ostedColormap([])\n",
    "p;t.pcolprmesg(x1,x2,y_hat,cmap=iris_cmap)\n",
    "plt.scatter(x[y==0,0],x[y==0,1],s=30,c='g')\n",
    "plt.scatter(x[y==1，0],x[y==1,1],s=30,c='r')\n",
    "plt.scatter(x[y==2，0],x[y==2,1],s=30,c='b')\n",
    "plt.rcPara,s['font.sans-serif']='Simhei'\n",
    "plx.xlabel('花瓣长度')\n",
    "plt.tlabel('hua'ban'kuan')\n",
    "plt.show"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
